package com.diandian.backend.dingding.data.controller;

import com.diandian.backend.dingding.data.service.DingdingDeptTreeExtendService;
import com.diandian.base.boot.starter.response.BaseResult;
import com.diandian.base.boot.starter.util.ResultUtil;
import com.diandian.backend.dingding.data.param.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * [钉钉]部门树扩展信息表
 *
 * @author zyz diandian@qq.com
 * @since 1.0.0 2025-11-07
 */
@RestController
@RequestMapping("/dept/tree/extend")
public class DingdingDeptTreeExtendController {

    @Autowired
    private DingdingDeptTreeExtendService iDingdingDeptTreeExtendService;

    /**
     * 查询详情
     */
    @PostMapping("/detail")
    public BaseResult getDetail(@RequestBody DingdingDeptTreeExtendDetailParam param) {
        param.check();
        return ResultUtil.makeResult(iDingdingDeptTreeExtendService.getDetail(param.toDTO()));
    }

    /**
     * 新增
     */
    @PostMapping("/sync")
    public BaseResult sync(@RequestBody DingdingDeptTreeExtendSyncParam param) {
        param.check();
        iDingdingDeptTreeExtendService.sync(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
    * 分页查询
    */
    @PostMapping("/page")
    public BaseResult page(@RequestBody DingdingDeptTreeExtendPageParam param) {
        param.check();
        return ResultUtil.makeResult(iDingdingDeptTreeExtendService.page(param.toDTO()));
    }

    /**
     * 根据数据id更新数据
     */
    @PostMapping("/updateById")
    public BaseResult updateById(@RequestBody DingdingDeptTreeExtendUpdateByIdParam param) {
        iDingdingDeptTreeExtendService.updateById(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 根据数据id删除数据
     */
    @PostMapping("/deleteById")
    public BaseResult deleteById(@RequestBody DingdingDeptTreeExtendDeleteByIdParam param) {
        param.check();
        iDingdingDeptTreeExtendService.deleteById(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 新增
     */
    @PostMapping("/add")
    public BaseResult add(@RequestBody DingdingDeptTreeExtendAddParam param) {
        iDingdingDeptTreeExtendService.add(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 列表查询
     */
    @PostMapping("/list")
    public BaseResult list(@RequestBody DingdingDeptTreeExtendListParam param) {
        return ResultUtil.makeResult(iDingdingDeptTreeExtendService.getList(param.toDTO()));
    }
}